home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / graphics / gnuplot / epsviewe.m < prev    next >
Text File  |  1993-09-15  |  3KB  |  86 lines

  1. #ifndef lint
  2. static char *RCSid = "$Id: epsviewe.m%v 3.50.1.6 1993/07/27 03:35:12 woo Exp $";
  3. #endif
  4.  
  5.  
  6. #import "epsviewe.h"
  7. #import <appkit/OpenPanel.h>
  8. #import <appkit/View.h>
  9.  
  10. @implementation EpsViewer
  11.  
  12. - windowCreate:(NXCoord) width Height:(NXCoord) height
  13. {
  14.     
  15.     /* create the new window, in a good place */
  16.     theNewWin = [Window
  17.         newContent:[self nextRectForWidth:width Height:height]
  18.         style:NX_TITLEDSTYLE
  19.         backing:NX_RETAINED
  20.         buttonMask:(NX_CLOSEBUTTONMASK | NX_MINIATURIZEBUTTONMASK)
  21.         defer:NO];
  22.     /* we need to receive windowDidBecomeMain: and windowDidResignMain: */
  23.     [theNewWin setDelegate:self];
  24.     /*
  25.          * create a new View, make it the contentView of our new window,
  26.      * and destroy the window's old contentView 
  27.      */
  28.         [[theNewWin setContentView:[[View alloc] init]] free];
  29.         /* display the window, and bring it forth */
  30.     [theNewWin display];
  31.     [theNewWin makeKeyAndOrderFront:self];    
  32. /*    [theNewWin orderBack:self];            */
  33.     /* show the frame */
  34.     return self;
  35. }
  36.  
  37. /***************************************************************************/
  38. /* nextRectForWidth:Height: - return the next good content rectangle       */
  39. /*  from Carl F. Sutter's wonderful ViewGif2 'Controller' method...        */
  40. /***************************************************************************/
  41. /* nextTopLeft - return the next good top left window position           */
  42. /***************************************************************************/
  43.  
  44. - (NXRect *)nextRectForWidth:(NXCoord)width Height:(NXCoord)height
  45. {
  46. #define OFFSET 10.0
  47. #define MAX_STEPS 20
  48. #define INITIAL_X 356.0
  49. #define INITIAL_Y 241.0
  50.     NXPoint         nxpTopLeft;
  51.     NXRect          nxrTemp;    /* used to find window height     */
  52.     NXRect          nxrWinHeight;    /* bounds of enclosing window     */
  53.     NXSize          nxsScreen;    /* size of screen         */
  54.     static NXRect   nxrResult;    /* the Answer!             */
  55.     static int      nCurStep = 0;
  56.  
  57.     /* find a good top-left coord */
  58.     nxpTopLeft.x = INITIAL_X + nCurStep * OFFSET;
  59.     nxpTopLeft.y = INITIAL_Y + nCurStep * OFFSET;
  60.     if (++nCurStep > MAX_STEPS)
  61.         nCurStep = 0;
  62.     /* find window height using nxrTemp */
  63.     nxrTemp.size.width = width;
  64.     nxrTemp.size.height = height;
  65.     nxrTemp.origin.x = nxrTemp.origin.y = 0;
  66.     [Window getFrameRect:&nxrWinHeight forContentRect:&nxrTemp
  67.      style:NX_TITLEDSTYLE];
  68.     [NXApp getScreenSize:&nxsScreen];
  69.     /* find the lower-left coord */
  70.     nxrResult.origin.x = nxpTopLeft.x;
  71.     nxrResult.origin.y = nxsScreen.height - nxrWinHeight.size.height - nxpTopLeft.y;
  72.     nxrResult.size.width = width;
  73.     nxrResult.size.height = height;
  74.     return (&nxrResult);
  75. }
  76.  
  77.  
  78. // Keep compiler quiet
  79. - (const char *) rcsid
  80. {
  81.     return RCSid;
  82. }
  83.  
  84. @end
  85.  
  86.